package com.hotel.service.impl;

import com.hotel.mapper.RoomMapper;
import com.hotel.pojo.Room;
import com.hotel.service.RoomService;
import com.hotel.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomServiceImpl implements RoomService {
    @Autowired
    private RoomMapper roomMapper;

    @Override
    public PageResult getRoomList(PageResult pageResult) {
        Long total = roomMapper.getTotal();
        int size = pageResult.getPageSize();
        int start = (pageResult.getPageNum() - 1) * size;
        String query = pageResult.getQuery();
        List<Room> rows = roomMapper.findRoomListByPage(start,size,query);
        return pageResult.setTotal(total).setRows(rows);
    }



}
